import 'package:win_helper/win_helper.dart';

class DisplayMonitor{
  static Future<List<DisplaySetting>> displayMonitorSetting() async{
    List<DisplaySetting> result = [];
    List<dynamic> ret = await WinHelper.channel.invokeMethod('getDisplayMonitorSetting');
    if(ret.isNotEmpty){
      for(var v in ret){
        result.add(DisplaySetting.fromMap(Map<String,dynamic>.from(v)));
      }
    }
    return result;
  }
}

class DisplaySetting{
  bool isPrimary = false;
  int x = 0;
  int y = 0;
  int width = 0;
  int height = 0;

  DisplaySetting.fromMap(Map<String,dynamic> data){
    if(data.containsKey('x')){
      x = data['x'];
    }
    if(data.containsKey('y')){
      y = data['y'];
    }
    if(data.containsKey('width')){
      width = data['width'];
    }
    if(data.containsKey('height')){
      height = data['height'];
    }
    if(data.containsKey('isPrimary')){
      isPrimary = data['isPrimary'];
    }
  }
}